<?php
require('includes/basic.php');
if(!isset($_SESSION['uid']))
				{
					echo "You are not authorised to view this page.";
				}
				else
				{
					

					if(isset($_GET['id']))
					{
					// if id is set then get the file with the id from database



					$id    = $_GET['id'];
					$query = "SELECT name, type, size, content FROM task_doc WHERE task_doc_id = '$id'";

					$result = mysql_query($query) or die('Error, query failed');
					list($name, $type, $size, $content) = mysql_fetch_array($result);

					header("Content-length: $size");
					header("Content-type: $type");
					header("Content-Disposition: attachment; filename=$name");
					echo $content;


					exit;
					}
				}
?>